from twisted.internet.protocol import Protocol, ServerFactory
from twisted.internet import reactor
from server import PServer
from common.netids import *
import cPickle as pickle

class PServerProtocol(Protocol, PacketHandler):
    def connectionMade(self):
        print "We're connected with a new remote client."
        
    def connectionLost(self, reason):
        print "A remote client has disconnected:" , reason
        
class PServerNet(ServerFactory):
    '''This class handles networking with the Twisted library.'''
    port = 0
    protocol = PServerProtocol
    def __init__(self, port):
        '''Initialize the networking. Starts the TCP port listening'''
        self.port = port
        reactor.listenTCP(port, self)
    
        
  
        
